package ar.fiuba.logger.reporter;

import java.util.Objects;

import ar.fiuba.logger.LogFormatterInterface;
import ar.fiuba.logger.LogMessageInterface;
import ar.fiuba.logger.LogReporter;

/**
 * The Class ConsoleReporter.
 * 
 * This class implements the console reporter. The console reporter output log messages to the
 * console.
 */
public class ConsoleReporter implements LogReporter {

  private LogFormatterInterface formatter;

  public ConsoleReporter(LogFormatterInterface formatter) {
    this.formatter = formatter;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object object) {
    if (this == object)
      return true;
    if (object == null)
      return false;
    if (getClass() != object.getClass())
      return false;
    return true;
  }

  /*
   * (non-Javadoc)
   * 
   * @see java.lang.Object#hashCode()
   */
  @Override
  public int hashCode() {
    return Objects.hashCode(this.getClass());
  }

  /*
   * (non-Javadoc)
   * 
   * @see fiuba.logger.reporter.Reporter#report(java.lang.String)
   */
  public void report(LogMessageInterface message) {
    String formattedMessage = formatter.format(message);

    System.out.println(formattedMessage);
  }
}
